﻿<UserControl x:Class="Locator.Silverlight.Client.ManagePersonalLocationsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:map="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    mc:Ignorable="d"
             DataContext="{Binding ManagePersonalLocations, Source={StaticResource Locator}}">
    <UserControl.Resources>
        <DataTemplate x:Key="PushPinTemplate">
            <map:Pushpin map:Location="{Binding Store.Location}">
                <TextBlock Foreground="Black" FontSize="10" TextAlignment="Center" Text="{Binding Index}"/>
            </map:Pushpin>
        </DataTemplate>
        <DataTemplate x:Name="LocationTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Description}" Width="350" VerticalAlignment="Center" />
                <Button Content="Remove" Width="55" Command="{Binding ManagePersonalLocations.RemoveLocationCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <map:Map Margin="387,12,12,238" CopyrightVisibility="Collapsed" Center="43.6,-79.5,0" ZoomLevel="8" Culture="en-CA" CredentialsProvider="{StaticResource MyCredentials}" Name="mapResults">
            <map:MapItemsControl x:Name="MapLocations" ItemTemplate="{StaticResource PushPinTemplate}" ItemsSource="{Binding PersonalLocations}"/>
        </map:Map>
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,298,0,0" Name="textBlockYourLocations" Text="Your Locations" VerticalAlignment="Top" />
        <ListBox Height="199" HorizontalAlignment="Left" Margin="12,327,0,0" Name="listBoxPersonalLocations" ItemsSource="{Binding UserLocations}" VerticalAlignment="Top" Width="437" ItemTemplate="{StaticResource LocationTemplate}" />
        <Button Content="Add" Height="23" HorizontalAlignment="Left" Margin="228,186,0,0" Name="ButtonAdd" VerticalAlignment="Top" Width="75" Command="{Binding AddLocationCommand}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,12,0,0" Name="textBoxAddress" VerticalAlignment="Top" Width="120" Text="{Binding Address, Mode=TwoWay}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,41,0,0" Name="textBoxCity" VerticalAlignment="Top" Width="120" Text="{Binding City, Mode=TwoWay}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,99,0,0" Name="textBoxPostalCode" VerticalAlignment="Top" Width="120" Text="{Binding PostalCode, Mode=TwoWay}"  />
        <ComboBox Height="23" HorizontalAlignment="Left" Margin="102,70,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Provinces}" SelectedItem="{Binding Province, Mode=TwoWay}">
        </ComboBox>
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,16,0,0" Name="textBlock1" Text="Street Address" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,45,0,0" Name="textBlock2" Text="City" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,74,0,0" Name="textBlock3" Text="Province" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,103,0,0" Name="textBlock4" Text="Postal Code" VerticalAlignment="Top" />
        <Button Content="Look Up" Height="23" HorizontalAlignment="Left" Margin="228,99,0,0" Name="ButtonLookUpPostalCode" VerticalAlignment="Top" Width="75" Command="{Binding LocatePostalCodeCommand}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,128,0,0" Name="textBoxLatitude" VerticalAlignment="Top" Width="120" Text="{Binding Mode=TwoWay, Path=Latitude, TargetNullValue=''}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,157,0,0" Name="textBoxLongitude" VerticalAlignment="Top" Width="120" Text="{Binding Longitude, Mode=TwoWay, TargetNullValue=''}" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,132,0,0" Name="textBlock5" Text="Latitude" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,161,0,0" Name="textBlock6" Text="Longitude" VerticalAlignment="Top" />
        <Button Content="Look Up" Height="23" HorizontalAlignment="Left" Margin="228,70,0,0" Name="ButtonLookUpAddress" VerticalAlignment="Top" Width="75" Command="{Binding LocateAddressCommand}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="102,186,0,0" Name="textBox6" VerticalAlignment="Top" Width="120" Text="{Binding Description, Mode=TwoWay}" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="14,190,0,0" Name="textBlock7" Text="Description" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="387,294,0,0" Name="textBlock8" Text="Click and drag the point to adjust its location" VerticalAlignment="Top" />
    </Grid>
</UserControl>
